import Vue from 'vue'
import VueRouter from 'vue-router'

//导入组件(懒加载的方式)
const Home = () => import('../views/home/Home')
const Profile = () => import('../views/profile/profile')
const Cart = () => import('../views/cart/cart')
const Category = () => import('../views/category/Categroy')


// 1 : 安装插件
Vue.use(VueRouter)

//2 : 创建router
const routes = [
  //默认页面(重定向)
  {
    path: '',
    redirect: "/home"

  },
  //首页
  {
    path: '/home',
    component: Home
  },
  //分类
  {
    path: '/category',
    component: Category
  },
  //购物车
  {
    path: '/cart',
    component: Cart
  },
  //我的
  {
    path: '/profile',
    component: Profile
  },

]
const router = new VueRouter({
  routes,
})

export default router
